/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package african11;

import java.io.IOException;
import static chanlib.Chan_IO.*;

/**
 * @author robit
 */
public class InvestingAtTheMarket{
    /*
      All neccesary to be defined
      including:
      variable, inner class
    */
    // static int A;
    // static void B();
    // static class C

    /*
       One calculation fits all of the cases.
    */
    static void preReckon(){
        return;
    }

    /*
      calculate the answer
    */
    private static void reckon(int line) {
        int M=Int();
        int P[]=new int[12];
        for(int i=0;i<12;i++){
            P[i]=Int();
        }
        int bestpro[]=new int[11];
        int bestmon[]=new int[11];

        for(int i=0;i<11;i++){
            int n=M/P[i];
            if(n==0)continue;
            for(int j=i+1;j<12;j++){
                if(bestpro[i]<n*(P[j]-P[i])){
                    bestpro[i]=n*(P[j]-P[i]);
                    bestmon[i]=j;
                }
            }
        }

        String ans;
        int bestpur=0;
        int bestsell=0;
        int maxprofit=0;
        for(int i=0;i<11;i++){
            if(bestpro[i]>maxprofit){
                maxprofit=bestpro[i];
                bestpur=i;
                bestsell=bestmon[i];
            }else if(bestpro[i]==maxprofit){
                if(P[i]<P[bestpur]){
                    maxprofit=bestpro[i];
                    bestpur=i;
                    bestsell=bestmon[i];
                }
            }
        }
        if(maxprofit>0)
            ans=String.format("%d %d %d", bestpur+1,bestsell+1,maxprofit);
        else ans="IMPOSSIBLE";
        String output=String.format("Case #%d: %s",line,ans);
        writeln(output, OUTFILE);
        //writeln(String.format("N=%d K=%d\n%s", N, K, ans),ANALFILE);
        //println(output);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        /*
           Pre-computing for all cases
        */

        // Just in case!
        //preReckon();
        //while((char)read()!='P');

        /*
          Input-output
        */
        boolean test=false;
        boolean small=false;
        String prob="B";
        String filename;
        if(test) filename="test";
        else{
            if(small) filename=prob+"-small-practice";
            else filename=prob+"-large-practice";
        }
        try {
            /*
               Init IO,plus determination of input line number
             */
            int lineNums = initFileIO(filename);
            for (int i = 1; i <= lineNums; i++) {
                reckon(i);
            }
        } finally {
            endIO();
        }
    }

}
